﻿$(document).ready(function () {
    // Register the handle for the close button when user click on it 
    $("#btnClose").click(function (e) {
        HideDialog();
        e.preventDefault();
    });
    // Register the handle for the submit button when user click on it
    $("#btnSubmit").click(function (e) {
        HideDialog();
        e.preventDefault();
    });
});

/**
    Show dialog with option Model
    Model = True: user cannot interact with the below elements of popup dialog
    False = False: opposite for case Model = True
*/
function ShowDialog(modal) {
    $("#overlay").show();
    $("#dialog").fadeIn(300);

    if (modal) {
        $("#overlay").unbind("click");
    }
    else {
        $("#overlay").click(function (e) {
            HideDialog();
        });
    }
}

/**
    Hide popup dialog
*/
function HideDialog() {
    $("#overlay").hide();
    $("#dialog").fadeOut(300);
}

/**
    Show popup dialog with data which is retrieved from PartialView
*/
function ShowPopupDialog_OnComplete(context) {
    $("#detail-info").html(context.get_data());
    // Show popup dialog
    ShowDialog(true);
    e.preventDefault();
}